#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e3 + 10;
const int M = 55;
const int mod = 1e9 + 7;

char s[N];
int n;
int D;
int f[2][N << 1][2][M][2];
pii nxt[N << 1][M][10];

void upd(int &x) { x = x + (x >> 31 & mod); }

template < int N > struct SAM {
	int ch[N][11], ndn, link[N], lst, len[N];
	SAM() { link[0] = -1; }
	void extend(const int &x) {
		int cur = ++ndn, p = lst; len[cur] = len[p] + 1; lst = cur;
		while(~p && !ch[p][x]) ch[p][x] = cur, p = link[p]; if(!~p) return link[cur] = 0, void();
		int q = ch[p][x]; if(len[q] == len[p] + 1) return link[cur] = q, void();
		int clo = ++ndn; rep(i, 0, 9) ch[clo][i] = ch[q][i]; link[clo] = link[q]; len[clo] = len[p] + 1;
		while(~p && ch[p][x] == q) ch[p][x] = clo, p = link[p]; link[q] = link[cur] = clo;
	}
	void build(char *s) { int l = strlen(s + 1); rep(i, 1, l) extend(s[i] - '0'); }
	pii getnxt(int p, int l, int x) {
		while(~link[p] && !ch[p][x]) p = link[p], l = len[p];
		if(ch[p][x]) l++, p = ch[p][x];
		return { p, min(l, D / 2) };
	}
	void init() {
		rep(i, 0, ndn) rep(j, 0, D / 2) rep(k, 0, 9) nxt[i][j][k] = getnxt(i, j, k);
	}
};

SAM < N << 1 > S;

int calc(char *x, int lim) {
	int o = 0; memset(f[o], 0, sizeof f[o]);
	f[o][0][1][0][0] = 1; int ans = 0;
	rep(i, 1, lim) {
		memset(f[o ^ 1], 0, sizeof f[o ^ 1]);
		rep(j, 0, S.ndn) rep(fl, 0, 1) rep(clen, 0, D / 2) rep(hap, 0, 1) if(f[o][j][fl][clen][hap]) {
			int up = fl ? x[i] - '0' : 9, dn = i == 1 ? 1 : 0;
			rep(d, dn, up) {
				pii nst = nxt[j][clen][d]; int stu = nst.fi, len = nst.se;
				upd(f[o ^ 1][stu][fl & (d + '0' == x[i])][len][(len >= D / 2) || hap]
					+= f[o][j][fl][clen][hap] - mod);
			}
		}
		o ^= 1;
	}
	rep(j, 0, S.ndn) rep(fl, 0, 1) rep(clen, 0, D / 2) upd(ans += f[o][j][fl][clen][1] - mod);
	cerr << ans << endl; return ans;
}

char x[N], y[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	scanf("%s", s + 1); n = strlen(s + 1); S.build(s);
	scanf("%s", x + 1); scanf("%s", y + 1); D = strlen(x + 1); S.init();
	x[D]--; int cur = D; while(x[cur] < '0') x[cur - 1]--, x[cur] += 10, cur--;
	int ans = calc(x, D); upd(ans = calc(y, D) - ans);
	printf("%d\n", ans); return 0;
}
